﻿@using WaterRevenueMS.Domain.ViewModels.Charge.MeterCharge;
@using WaterRevenueMS.Domain.ViewModels.AdminCommon
@model MeterChargeModel
@{
    ViewBag.Title = ViewBag.CurrentTitle + " - 潍微水务管理系统";

    var editButton = new ButtonModel();
    editButton = ViewBag.Edit;

  
}
@section css{
     <link href="@Url.Content("~/Content/themes/base/jquery.ui.core.css")" rel="Stylesheet" type="text/css"/>  
     <link href="@Url.Content("~/Content/themes/base/jquery.ui.autocomplete.css")" rel="Stylesheet" type="text/css"/> 
     <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="Stylesheet" type="text/css"/> 
     <link href="@Url.Content("~/Content/themes/base/jquery.ui.theme.css")" rel="Stylesheet" type="text/css"/> 
}

<div id="content-body" class="row-fluid">
    <div class="span22">
        <!--操作 -->
        @Html.Partial("Search", Model.Search)

        <!--列表-->
        @Html.Partial("List")

        <!--新增 & 编辑-->
        @Html.Partial("_FormModal")
    
    </div>
</div>

@section scripts{
    <script src="@Url.Content("~/Scripts/jquery-ui-1.10.4.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-zh.js")" type="text/javascript"></script>
    <script type="text/javascript">
        var oTable = null;

        //附带不用修改浏览器安全配置的javascript代码，兼容ie， firefox全系列

function getPath(obj)  
{  
  if(obj)  
    {  
 
    if (window.navigator.userAgent.indexOf("MSIE")>=1)  
      {  
        obj.select();  
 
      return document.selection.createRange().text;  
      }  
 
    else if(window.navigator.userAgent.indexOf("Firefox")>=1)  
      {  
      if(obj.files)  
        {  
 
        return obj.files.item(0).getAsDataURL();  
        }  
      return obj.value;  
      }  
    return obj.value;  
    }  
}  
//参数obj为input file对象

        $("#chkAll").click(function () {
            if (this.checked) {
                $("input[type='checkbox']").each(function () { this.checked = true; });
            }
            else {
                $("input[type='checkbox']").each(function () { this.checked = false; });
            }
        });

        var strListID = "";
        $("#Getchk").click(function () {

                strListID="";
                $("input[type='checkbox']").each(function () {  
                    if(this.checked)
                    {
                    strListID += this.value+","
                    }
                });
               $.ajax({
                url: "/MeterCharge/GenerateRepair?idList="+ strListID,
                type: "get",
                cache: false,
                dataType: 'json',
                success: function (data) {
                    alert(data.message);
                },
                error: function () {
                   
                }
            });
 
        } );
        var strExlUrlID = "";
        $("#CheckEXL").click(function () {

                strExlUrlID="";
                $("input[type='file']").each(function () {  
               //  alert($(this).val());
           //   var obj = document.getElementById('exl');
            var url = getPath(document.getElementById("exl"))
            function getPath(obj) {
             if (obj) {
              if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
               obj.select();
               return document.selection.createRange().text;
              } else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
               if (obj.files) {
                return obj.files.item(0).getAsDataURL();
               }
               return obj.value;
              }
              return obj.value;
             }
            }
                    strExlUrlID = url;
                });
               $.ajax({
                url: "/MeterCharge/GenerateChargeEXL?idList="+ strExlUrlID,
                type: "get",
                cache: false,
                dataType: 'json',
                success: function (data) {
                    alert(data.message);
                },
                error: function () {
                   
                }
            });
 
        } );
   
        $(function () {
            var actionUrl = "@Url.Action("List")?rand=" + Math.random();
            var aoColumns = [
                    {
                        "bSearchable": false,
                        "bSortable": false,
                        "fnRender": function (oObj) {
                            var btnArray = "";
                            
                            @if (editButton != null)
                            {
                                <text>btnArray += '<input type="checkbox"  value='+oObj.aData[oObj.aData.length - 1]+'>'</text>
                            }
                            return btnArray;
                        }
                    },
                    
                    { "sName": "SortId", "bSortable": false },
                    { "sName": "UserName", "bSortable": false },
                    { "sName": "Yong_HDZ", "bSortable": false },
                    { "sName": "Yong_HYE", "bSortable": false },
                    { "sName": "Ben_QDS", "bSortable": false },
                     { "sName": "Shang_QDS", "bSortable": false },
                     { "sName": "Ben_QYL", "bSortable": false },
                     { "sName": "He_JYL", "bSortable": false },
                     { "sName": "Ben_CJF", "bSortable": false },
          
                    { "sName": "CreateDT", "bSortable": false },
                    { "sName": "Bei_Z", "bSortable": false }
            ];
            //初始化表格
            oTable = InitDatatables($(".data-table"), actionUrl, aoColumns, oTable);
        });

                //查询
           function Search() {
                    var filterdata = $(".search-form").serialize();
                    var actionUrl = "@Url.Action("List")?rand=" + Math.random() + "&" + filterdata;
            SearchRecord(actionUrl, oTable);
        }

        
          function Edit(id) {
            var actionUrl = "@Url.Action("Edit")";
            var param = { Id: id }
            ShowModal(actionUrl, param, "打印收费单");
            }

           //保存
        function Save() {
            SaveModal(oTable);
        }

        function GenerateRepair(id)
        {   
        
            $.get("GenerateRepair", { 
                        username :  $("#username").val() , //传入参数
                       
                    }, function (){
                        alert("成功");
                    }
            );
        }

    </script>
}
